Skip to content

Reject CR/LF in POP3 command arguments#31

Merged
hsbt merged 1 commit into
masterfrom
reject-crlf-in-commands
Jun 10, 2026
Merged

Reject CR/LF in POP3 command arguments#31
hsbt merged 1 commit into
masterfrom
reject-crlf-in-commands

Conversation

@hsbt

@hsbt hsbt commented Jun 10, 2026

Copy link
Copy Markdown
Member

The account and password passed to USER, PASS, and APOP were interpolated into command lines without rejecting CR/LF, so an application forwarding untrusted input as login arguments could inject arbitrary POP3 commands. Add the same validate_line guard already present in net-smtp and net-ftp.

As with ruby/net-http#301, these are ordinary bugs rather than vulnerabilities, since the affected inputs are supplied by the application itself.

Copilot AI review requested due to automatic review settings June 10, 2026 02:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents POP3 command injection by rejecting any CR or LF characters in command lines before writing to the socket, specifically protecting USER, PASS, and APOP argument interpolation.

Changes:

  • Add a validate_line guard in Net::POP3Command#getok and #get_response to raise ArgumentError if the command line contains \r or \n.
  • Add regression tests ensuring Net::POP3#start rejects CRLF injection attempts via username/password.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/net/pop.rb Adds validate_line and applies it to all POP3 command writes via getok/get_response to prevent CR/LF injection.
test/net/pop/test_pop.rb Adds tests that assert ArgumentError is raised when CRLF is present in POP3 login arguments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The account and password supplied to USER, PASS, and APOP were
interpolated into command lines and written to the socket without
neutralizing CR/LF, so an application forwarding untrusted input as
login arguments could inject arbitrary POP3 commands. This mirrors the
validate_line guard already present in net-smtp and net-ftp. As with the
net-http change, the affected inputs come from the application itself, so
this is treated as a bug rather than a vulnerability.

Reported-by: tonghuaroot <23011166+tonghuaroot@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hsbt hsbt force-pushed the reject-crlf-in-commands branch from d1a8153 to 6de982d Compare June 10, 2026 02:45
@hsbt hsbt merged commit 0e54ed7 into master Jun 10, 2026
80 checks passed
@hsbt hsbt deleted the reject-crlf-in-commands branch June 10, 2026 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants